<template>
  <div class="classroomMamage">
    <el-card>
      <div class="search_wrap">
        <div class="top-tip">{{top_tip}}</div>
        <div class="top-nav">
          <div :class="nav_index === 0?'nav-item active':'nav-item'" @click="navClick(0)">在线用户数</div>
          <div :class="nav_index === 1?'nav-item active':'nav-item'" @click="navClick(1)">并发统计</div>
          <div :class="nav_index === 2?'nav-item active':'nav-item'" @click="navClick(2)">云存储情况</div>
        </div>
      </div>

      <div class="table_list" >
         <!-- 在线用户数 -->
        <div v-if="nav_index===0">
          <el-table 
          ref="nicheTable"
          :data="tableListData"
          min-height="500"
          border
          v-loading="loading"
          style="width: 100%;margin-top:20px"
        >
          <el-table-column
            v-for="(item,index) in tableCaption1"
            :key="index"
            :label="item.label"
            align="center"
            :width="item.width"
          >
            <template slot-scope="scope">
              <span>{{ scope.row[item.value]}}</span>
            </template>
          </el-table-column>
        </el-table>
        </div>
        <!-- 并发统计 -->
        <div v-if="nav_index===1">
          <el-table 
          ref="nicheTable"
          :data="tableListData"
          min-height="500"
          border
          v-loading="loading"
          style="width: 100%;margin-top:20px"
        >
          <el-table-column
            v-for="(item,index) in tableCaption2"
            :key="index"
            :label="item.label"
            align="center"
            :width="item.width"
          >
            <template slot-scope="scope">
              <span>{{ scope.row[item.value]}}</span>
            </template>
          </el-table-column>
        </el-table>
        </div>
        <!-- 云存储情况 -->
        <div v-if="nav_index===2">
          <el-table 
          ref="nicheTable"
          :data="tableListData"
          min-height="500"
          border
          v-loading="loading"
          style="width: 100%;margin-top:20px"
        >
          <el-table-column
            v-for="(item,index) in tableCaption3"
            :key="index"
            :label="item.label"
            align="center"
            :width="item.width"
          >
            <template slot-scope="scope">
              <span>{{ scope.row[item.value]}}</span>
            </template>
          </el-table-column>
        </el-table>
        </div>
        <link-pagination
          :total="total"
          :currentPage="currentPage"
          :limit="limit"
          v-if="total != 0"
          @pagination="getPaginationParams"
        ></link-pagination>
      </div>
    </el-card>
  </div>
</template>
<script>
import statisticsTag from "@/components/statisticsTag";
import { paginationMixin } from "@/mixin";
import http from "@/api/room";
import { formatDate, formatArray } from "@/utils";
export default {
  name: "statistics",
  mixins: [paginationMixin],
  components: {
    statisticsTag
  },
  data() {
    return {
      http: http,
      topNavTextList:['在线用户数','并发统计',"云存储情况"],
      nav_index: 0,
      top_tip: "在线用户数",
      tableListData: [],
      loading: false, //加载状态
      total: 0,
      tableCaption1: [
        {
          label: "教室号",
          value: "serial",
          width: 100
        },
        {
          label: "教室名称",
          value: "roomname",
          width: 200
        },
        {
          label: "开始时间",
          value: "starttime",
          width: 200
        },
        {
          label: "结束时间",
          value: "endtime",
          width: 200
        }
      ],
      tableCaption2: [
        {
          label: "时间",
          value: "serial",
          width: 100
        },
        {
          label: "一对一",
          value: "roomname",
          width: 200
        },
        {
          label: "一对多",
          value: "starttime",
          width: 200
        },
        {
          label: "直播",
          value: "endtime",
          width: 200
        },
        {
          label: "机器人数量",
          value: "endtime",
          width: 200
        }
      ],
      tableCaption2: [
        {
          label: "时间",
          value: "serial",
          width: 100
        },
        {
          label: "文件占用空间(M)",
          value: "roomname",
          width: 200
        },
        {
          label: "录制件占用空间(M)",
          value: "starttime",
          width: 200
        },
        {
          label: "总存储空间(M)",
          value: "endtime",
          width: 200
        }
      ]
    };
  },
  methods: {
    //路由跳转
    goToURL(name, params) {
      this.$router.push({ name, params });
    },
    goToURL(name, query) {
      this.$router.push({ name, query });
    },
    //导航点击
    navClick(index){
      console.log(index)
      this.nav_index = index;
      this.top_tip = this.topNavTextList[index]
    },
    getListData(
      page = this.currentPage,
      list_rows = this.limit,
    ) {
      this.loading = true;
      let params = { page,list_rows}
      // http.getList(params).then(res => {
      //   this.loading = false;
      //   this.total = res.data.total;
      //   let tableListData = res.data.data;
      //   this.tableListData = tableListData;
      // });
    },
    init() {
      this.getListData();
    },
  },
  created() {
    this.init();
  }
};
</script>
<style lang="scss" scoped>
.classroomMamage {
  padding: 10px;
  .search_wrap {
    .top-tip {
      color: #2f9ceb;
      font-size: 24px;
      display: block;
      height: 30px;
      line-height: 30px;
      padding-left: 15px;
      margin-top: 40px;
      border-left: 2px solid #2f9ceb;
      margin-bottom: 20px;
    }
    .top-nav {
      display: inline-block;
      border: 1px solid #2f9ceb;
      border-radius: 4px;
      .nav-item{
        float: left;
        padding: 5px 10px;
        margin-left: 0;
        cursor:pointer;
      }
      .nav-item:nth-child(2),
      .nav-item:nth-child(3) {
        border-left: 1px solid #2f9ceb;
      }
      .active {
        background: #2f9ceb;
        color: #fff;
      }
    }
  }
  .opt_wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 34px;
    &_left {
      display: flex;
      p {
        margin-right: 18px;
        color: #565656;
        font-size: 16px;
        cursor: pointer;
        &:hover {
          color: #1796eb;
        }
        &:nth-of-type(1) {
          cursor: default;
          color: #646464;
          &:hover {
            color: #646464;
          }
        }
      }
    }
    &_right {
      display: flex;
      align-items: center;
      p {
        margin-left: 18px;
        color: #565656;
        font-size: 16px;
        cursor: pointer;
        &:hover {
          color: #1796eb;
        }
      }
      .add {
        width: 72px;
        height: 30px;
        background: linear-gradient(top left, #17b5eb, #1796eb);
        display: flex;
        justify-content: center;
        align-items: center;
        color: white;
        cursor: pointer;
        border-radius: 5px;
        &:hover {
          color: white;
        }
      }
    }
  }
  .search_wrap {
    margin-top: 34px;
    margin-bottom: 34px;
  }
  .see_detail {
    cursor: pointer;
    color: #1796eb;
  }
  .btn {
    margin-top: 30px;
    width: 100%;
    display: flex;
    justify-content: center;
    /deep/ .el-button {
      width: 214px;
    }
  }
  .del_modal {
    .content {
      display: flex;
      flex-direction: column;
      align-items: center;
      p {
        &:nth-of-type(1) {
          width: 92px;
          height: 92px;
          border-radius: 50%;
          background: linear-gradient(to bottom, #f25851, #f27350);
          display: flex;
          justify-content: center;
          align-items: center;
          margin-bottom: 18px;
          i {
            font-size: 40px;
            color: white;
          }
        }
        &:nth-of-type(2) {
          font-size: 20px;
          color: #333;
        }
        &:nth-of-type(3) {
          font-size: 14px;
          color: #999;
          margin-top: 7px;
        }
      }
    }
  }
  .operation {
    cursor: pointer;
    color: rgb(47, 156, 235);
  }
}
.el-table .success-row {
  background: #f0f9eb;
}
</style>